package com.common;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

/**
 * Created by Administrator on 2018-8-20 0020.
 */
public class EncrytPropertyPlaceholderConfig extends PropertyPlaceholderConfigurer {

    private String[] encrytPropArr = {"jdbc.username", "jdbc.password"};


    private boolean isEncrytProp(String propertyName) {
        for (String str : encrytPropArr) {
            if (str.equals(propertyName)) {
                return true;
            }
        }
        return false;
    }

    protected String convertProperty(String propertyName, String propertyValue) {
        if (isEncrytProp(propertyName)) {
            String decryptValue = DESUtils.getDecryptString(propertyValue);
            return decryptValue;
        }
        return propertyValue;
    }
}
